define('passport/login',function(){
	if(window.parent!=window){
		window.parent.location.href='/passport/login'
	}
	var ViewModel = function(){
		var self = this;
		self.userInfoModel = ko.observable({
			uname:'',
			password:''
		});
		self.login = function(data){
			
			var e = event || window.event || arguments.callee.caller.arguments[0];
			if(e && (e.keyCode == 13)){
				if(data.uname == ""|| data.password == ""){
					return;
				}
				console.log(data);
				var url = "/passport/doFindNameByPw";
				$.ajax({
					url:url,
					data:JSON.stringify(data),
					type:"post",
					dataType:"json",
					contentType:"application/json;charset=UTF-8",
					success:function(result){
						console.log(result);
						if(result.code == 1 || result.code == 2 || result.code == 3){
							$("#userdo").html(result.msg);
							return;
						}
						if(result.code ==0){
							sessionStorage.setItem("uname", data.uname);
							window.location.href='/';
						}
					}
				});
			}else{
				if(data.uname == ""|| data.password == ""){
					return;
				}
				console.log(data);
				var url = "/passport/doFindNameByPw";
				$.ajax({
					url:url,
					data:JSON.stringify(data),
					type:"post",
					dataType:"json",
					contentType:"application/json;charset=UTF-8",
					success:function(result){
						console.log(result);
						if(result.code == 1 || result.code == 2 || result.code == 3){
							$("#userdo").html(result.msg);
							return;
						}
						if(result.code ==0){
							sessionStorage.setItem("uname", data.uname);
							window.location.href='/';
						}
					}
				});
			}
		}
		self.reset = function(){
			self.userInfoModel({
				uname:'',
				password:''
			});
		};
	}
	var model = new ViewModel();
	ko.applyBindings(model);
})